/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-09-04
 * Time: 16:33
 */
public class Demo4 {
    public static void main(String[] args) {
        //runnable匿名内部类作为参数传给Thread的构造方法
        Thread thread = new Thread(new Runnable() {//实现了runnable 接口的类 被Runnable接口引用 作为参数传给Thread
            @Override
            public void run() {
                System.out.println("hello thread");
                try {
                    Thread.sleep(1_000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        thread.start();
        while (true){
            System.out.println("hello main");
            try {
                Thread.sleep(1_000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
